/*  ------------------------------------------------------------------------  */
/*  Paper        : Does Stakeholder Outrage Determine Executive Pay?          */
/*  Program      : a01-06-iss.do                                              */
/*  Description  : ISS governance variables                                   */
/*  ------------------------------------------------------------------------  */

/*  ------------------------------------------------------------------------  */
//  Import ISS governance dataset

import sas using "$iss/governance/rmgovernance.sas7bdat", clear

rename *, lower
format meetingdate %tdCCYY-NN-DD
#delimit ;
keep	cusip year fyend meetingdate
		blankcheck cboard confvote cumvote dualclass fairprice gparachute 
		lspmt ppill lwcnst resign_require
		law_amend_votepcnt charter_amend_votepcnt supermajor_pcnt
; #delimit cr

rename fyend fyear 

foreach var of varlist blankcheck cboard confvote cumvote dualclass ///
fairprice gparachute lspmt ppill lwcnst {
	gen g_`var'_d = upper(`var') == "YES"
	tab `var' g_`var'_d
}

replace g_lwcnst_d = 1 if upper(lwcnst) == "UNANIMOUS"

gen g_resign_require_d = upper(resign_require) == "NO"
tab g_resign_require_d

foreach var of varlist law_amend_votepcnt charter_amend_votepcnt supermajor_pcnt {
	gen g_`var'_d = (`var' >= 66)
	tab `var' g_`var'_d
}

gen g_index = g_blankcheck_d + g_cboard_d + g_confvote_d + g_cumvote_d + g_dualclass_d + g_fairprice_d + g_gparachute_d + g_lspmt_d + g_ppill_d + g_lwcnst_d + g_resign_require_d

keep year cusip g_*
gen ncusip = substr(cusip,1,8)
drop cusip

/*  ------------------------------------  */
//  Ensuring no duplicates in panel
egen ncusip_id = group(ncusip)

by ncusip_id year, sort: egen firmcount = count(year)
tab firmcount
// br if firmcount==2
drop ncusip_id firmcount

save "$temp112/rmgovernance.dta", replace

/*  -|----------------------------------------------------------------------  */
/*  ||  ---    Program end: a01-06-iss.do                                     */
/*  -|  ---    Attila Balogh    --------------------------------------------  */